layui.use(['layer', 'form', 'admin', 'ax','upload','formSelects'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;
    var layer = layui.layer;
    var upload = layui.upload;
    var formSelects=layui.formSelects;
    /**
     * 检索店名
     */
    // var languageAjax = new $ax(Feng.ctxPath + "/btyBxda/getDm");
    // var languageResult = languageAjax.start();
    // $.each(languageResult, function( index, val ) {
    //     $("#dm").append("<option value='"+val.dm+"'>"+val.dm+"</option>");
    // } );
    // form.render('select');
   // formSelects.render('dm');

    var ajax = new $ax(Feng.ctxPath + "/btyBxda/info?id=" + $("#id").val());
    var result = ajax.start();
    var flag=result.roleFlag;
    if(flag==1){
        // $("#dm").attr("disabled","disabled");
        // $("#kj").attr("disabled","disabled");
    }
    form.val('noticeForm', result);

    //回填店名
    //formSelects.value('dm', (result.dm).split(","));


    function bankCode() {
        var yhk=$("#yhk").val();
        if(yhk==""){
            alert("请输入银行卡号！");
            return;
        }
        var bankAjax = new $ax(Feng.ctxPath + "/btyBxda/bankCode?bankNo="+yhk+"");
        var bankCode=bankAjax.start();
        if(bankCode==""){
            $("#bz").val("")
            alert("识别错误！");
        }else{
            $("#bz").val(bankCode);
        }
    };
    // 导出excel
    $('#btnExp').click(function () {
        bankCode();
    });

    // 表单提交事件
    form.on('submit(btnSubmit)', function (data) {
        $("#dm").removeAttr("disabled","disabled");
        var ajax = new $ax(Feng.ctxPath + "/btyBxda/update", function (data) {
            Feng.success("保存成功！");

            //传给上个页面，刷新table用
            admin.putTempData('formOk', true);

            //关掉对话框
            admin.closeThisDialog();

        }, function (data) {
            Feng.error("保存失败！" + data.responseJSON.message)
        });
        ajax.set(data.field);
        ajax.start();

        //添加 return false 可成功跳转页面
        return false;
    });

});